#ifndef APIMANAGER_H
#define APIMANAGER_H

#include <QObject>
#include <QString>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include <QJsonArray>
#include <QJsonObject>

class ApiManager : public QObject
{
    Q_OBJECT
public:
    explicit ApiManager(QObject *parent = nullptr);
    static ApiManager* GetInstance();

    Q_INVOKABLE void getLiveResource(); // 获取节目列表

signals:
    void sig_serverError(QString errorInfo); // 服务器错误
    void sig_getLiveResourceDone(QJsonArray itemList); // 获取节目列表完成

private slots:
    void httpError(QNetworkReply::NetworkError);

private:
    QNetworkAccessManager *manager;
    QJsonArray parseItemList(QString itemList); // 解析节目列表
};

#endif // APIMANAGER_H
